Skip to content

Bridge S5: offer pool — claim-style distribution (#14371) - #14442

Merged
developing-today-fleet[bot] merged 2 commits into
mainfrom
felix/14371-bridge-offer-pool
Nov 24, 2026
Merged

developing-today-fleet[bot] merged 2 commits into
mainfrom
felix/14371-bridge-offer-pool

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Implements bridge build-out slice S5 (design doc/2026-11-24_design_message-bridge-buildout.md §4.2): the offer pool in pkgs/message-bridge/worker.

Refs #14371 — left unmerged for Felix's review.

What

Fan-out cannot express "the next task goes to the next N agents who pick it up", so a sender can now post an offer, stored once and never fanned out:

  • New tables fleet_offer (id, batch, body, kind, pattern, slots, sender, sender_addr, ts, expires_at, state) and fleet_offer_claim (offer_id, agent, claimed_at, message_id). (sender is one column beyond the design's list: the sender label a delivered mailbox row must carry, the same label a fan-out send writes.)
  • Post: POST /api/<owner>/fleet/offer {body, to, kind?, slots, sender?, ttl_seconds?} and POST /fleet/<token>/offer for agents (from_addr fixed to the poster's own name; a per-agent credential needs the send scope).
  • Eligible agents — the offer's address (name, glob, group or all) matched against the registry at claim time — see open offers in a new offers section of the inbox response and at GET /fleet/<token>/offers.
  • Claim: POST /fleet/<token>/claim {agent, offer_id} is one atomic store op. The claim row is a conditional INSERT that lands only while a slot remains on an open offer and the agent has not already claimed, so racing claims cannot oversubscribe; a winning claim delivers a normal mailbox row on the offer's batch and records the claim. Past the last slot the answer is a definite filled and no row exists; expired offers answer expired, a repeat claim already claimed, an ineligible agent not eligible, and the poster can never claim its own offer.
  • Anonymity unchanged: a command (instruction) offer is projected sender-free to eligible agents and to claimants (commandForAgent, as for any command); the store row and owner views keep the real sender.
  • Owner reads: GET /api/<owner>/fleet/offers lists every offer with slots, effective state (open/filled/expired), claim count and its claims (agent, time, delivered row id); claimants' replies thread onto the offer batch via the existing post op, so the pipeline's batch filter shows delivery + replies together (covered by a test).

Verification (remote only)

fleet-command run 45423029523 on developing-today/fleet, conclusion success, log shows Target HEAD: 9096d3e2428c72448162fde02a182920acdcf062 (this branch's head) and the full worker suite under the bun-test fallback (the executor image has no node — code#14267 / dezren39/fleet#111): 103 pass / 0 fail, 103 tests across 11 files — the 93 from S1–S3 plus 10 new tests in test/offers.test.mjs, all passing by name:

  • slots 2 claimed by three eligible agents: exactly the first two delivered, the third filled, no mailbox row for it
  • an agent outside the pattern can neither see nor claim it (incl. an unregistered claimant)
  • a claimant's reply threads onto the offer batch; pipeline batch filter shows delivery + reply; owner list names the claimant
  • an instruction offer reaches claimants sender-stripped; the owner sees the real sender (owner-posted and agent-posted)
  • concurrent claims (5 claimants, slots 2, issued together) cannot oversubscribe: exactly 2 win, 2 mailbox rows
  • claim after expiry refused; offer reads expired and leaves the open list
  • double-claim by the same agent refused, nothing delivered twice
  • the poster cannot claim its own offer
  • offer/claim input validation
  • a per-agent credential claims and posts only as itself, within its scopes (send-only credential: claim is the plain 404; both-scope credential: claiming for another agent is a 404)

Acceptance mapping: every #14371 acceptance item is covered by a named test above. No new dependencies.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-24T15:29:24Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/issue-14371/wt",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/issue-14371/wt",
      "repo": "developing-today/code",
      "branch": "felix/14371-bridge-offer-pool",
      "sha": "9096d3e2428c72448162fde02a182920acdcf062"
    },
    "auth_subject": "felix",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Design §4.2: a sender posts work once as an offer {body, kind, slots,
to: <pattern|group|all>} in the new fleet_offer table instead of
fanning it out. Eligible agents (address matched against the registry
at claim time) see open offers in a new inbox section and claim with
one atomic store op: the claim is a conditional INSERT that lands
only while a slot remains on an open offer and the agent has not
claimed, so racing claims cannot oversubscribe. A winning claim
delivers a normal mailbox row on the offer's batch (replies thread
onto the batch) and records fleet_offer_claim; past the last slot the
answer is a definite 'filled' with no row. Offers may carry a
ttl_seconds, after which claims answer 'expired' and the offer reads
expired. A command offer reaches claimants sender-stripped like every
command; the owner reads every offer with its claims (agent, time,
delivered row) at GET /api/<owner>/fleet/offers, and claims/replies
through the pipeline's batch filter. Agents can post offers too
(from_addr fixed to their own name; the poster never claims its own
offer), and per-agent credentials gate claim/offer by scope (inbox /
send) and own name, refusals the usual plain 404.

fleet_offer gains a sender label column alongside the design's
sender_addr so a delivered row carries the same sender a fan-out send
would have written.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e41e8bb1-fbdb-420a-ae77-a91463711541

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…fer-pool

# Conflicts:
#	pkgs/message-bridge/worker/README.md
#	pkgs/message-bridge/worker/src/fleet.js
@developing-today-fleet

Copy link
Copy Markdown
Contributor Author

Merge-refresh after S7 (#14431) landed on main: merged origin/main into the branch (merge commit 40d4e91, no rebase). Conflicts were unions in two files — src/fleet.js agentRoute (the offer/claim routes now sit alongside S7's read-scope routes; the credential offer-post also adopts S7's service-address semantics, from_addr = cred.addr ?? agent:) and README.md (both route-table additions kept). routes.js auto-merged.

Re-verified remotely on the merged head: fleet-command run 45426338395, conclusion success, Target HEAD 40d4e91 in the log; full worker suite 108 pass / 0 fail across 12 files (the 103 from the first verification + S7's 5 service-credential tests). PR is mergeable/CLEAN again, still unmerged for Felix's review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants